//
//  MCNewGoodsAddImagesCell.swift
//  StoreManage
//
//  Created by MC on 2018/2/6.
//  Copyright © 2018年 MC. All rights reserved.
//

import UIKit

protocol MCNewGoodsAddImagesCellDelegate : NSObjectProtocol{
    func MCNewGoodsAddImagesCellCancel(row:Int)
}

class MCNewGoodsAddImagesCell: UICollectionViewCell {
    
    var row = 0
    
    weak var delegate : MCNewGoodsAddImagesCellDelegate?
    
    override init(frame: CGRect) {
        super.init(frame: frame)
        
        
        self.addSubview(bgImageView)
        bgImageView.snp.remakeConstraints { (make) ->Void in
            make.edges.equalTo(self)
        }
        
        self.addSubview(cancelButton)
        cancelButton.snp.remakeConstraints { (make) ->Void in
            make.right.top.equalTo(self)
            make.size.equalTo(CGSize.init(width: 20, height: 20))
        }
        
        
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    @objc func cancelButtonClicked(sender:UIButton) {
        delegate?.MCNewGoodsAddImagesCellCancel(row: row)
    }
    
    
    lazy var bgImageView: UIImageView = {
        let imageView = UIImageView()
        imageView.layer.borderColor = UIColor.MCGray_light.cgColor
        imageView.layer.borderWidth = 1
        imageView.contentMode = UIViewContentMode.scaleAspectFill
        imageView.clipsToBounds = true
        return imageView
    }()
    
    lazy var cancelButton: UIButton = {
        let button = UIButton.init(type: UIButtonType.custom)
        button.setImage(#imageLiteral(resourceName: "GoodsManage_delete"), for: UIControlState.normal)
        button.addTarget(self, action: #selector(cancelButtonClicked), for: UIControlEvents.touchUpInside)
        return button
    }()
}
